﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IN = Criteria.Interface;
using OC = Criteria.OneCriteria;

namespace Criteria.TwoCriteria
{
  public  class OrCriteria:IN.Criteria
    {
        IN.Criteria criteria;
        IN.Criteria otherCriteria;

        public OrCriteria(IN.Criteria criteria, IN.Criteria otherCriteria)
        {
            this.criteria = criteria;
            this.otherCriteria = otherCriteria;
        }

        public List<IN.Person> MeetCriteria(List<IN.Person> list)
        {
            List<IN.Person> firstList = criteria.MeetCriteria(list);
            List<IN.Person> secondList = otherCriteria.MeetCriteria(list);
            foreach (var item in firstList)
            {
                if (secondList.Contains(item) == false)
                {
                    secondList.Add(item);
                }
            }
            return secondList;
        }
    }
}
